package cn.tedu.study.exammodel.controller;

import cn.tedu.study.exammodel.entity.dto.MultiQuestionAddDTO;
import cn.tedu.study.exammodel.entity.pojo.MultiQuestion;
import cn.tedu.study.exammodel.mapper.MultiQuestionMapper;
import cn.tedu.study.response.ResultVO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author:yuziji
 * @create: 2023-07-08 10:20
 * @description:
 */
@RestController
@RequestMapping("/v1/multi")
public class MultiQuestionController {
    @Autowired
    private MultiQuestionMapper multiQuestionMapper;
    @RequestMapping("/add")
    public ResultVO addNew(@RequestBody MultiQuestionAddDTO multiQuestionAddDTO){
        MultiQuestion multiQuestion = new MultiQuestion();
        BeanUtils.copyProperties(multiQuestionAddDTO,multiQuestion);
        String questionId = "10001"+multiQuestion.getId();
        multiQuestion.setQuestionId(Integer.parseInt(questionId));
        multiQuestionMapper.insert(multiQuestion);
        return ResultVO.ok();
    }

}
